package com.xxx.question.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xxx.common.utils.PageUtils;
import com.xxx.common.utils.Query;

import com.xxx.question.dao.QmsTypeDao;
import com.xxx.question.entity.QmsTypeEntity;
import com.xxx.question.service.QmsTypeService;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;


@Service("qmsTypeService")
public class QmsTypeServiceImpl extends ServiceImpl<QmsTypeDao, QmsTypeEntity> implements QmsTypeService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String classify = (String) params.get("key");

        QueryWrapper<QmsTypeEntity> queryWrapper = new QueryWrapper<>();
        if (!StringUtils.isEmpty(classify)) {
            queryWrapper.eq("id","key").or().like("type",classify);
        }

        IPage<QmsTypeEntity> page = this.page(
                new Query<QmsTypeEntity>().getPage(params), queryWrapper
        );
        return new PageUtils(page);
    }

    @Override
    public List<QmsTypeEntity> findAll() {
        return this.list();
    }

}